package cn.com.dashihui.web.controller;

import java.util.ArrayList;
import java.util.List;

import com.jfinal.aop.Duang;
import com.jfinal.kit.PropKit;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Record;

import cn.com.dashihui.kit.DatetimeKit;
import cn.com.dashihui.kit.ExcelExportUtil.Pair;
import cn.com.dashihui.web.base.BaseController;
import cn.com.dashihui.web.dao.Category;
import cn.com.dashihui.web.dao.GoodsSale;
import cn.com.dashihui.web.dao.GoodsSaleItem;
import cn.com.dashihui.web.dao.GoodsStore;
import cn.com.dashihui.web.dao.GoodsTokerValue;
import cn.com.dashihui.web.dao.Seller;
import cn.com.dashihui.web.dao.Store;
import cn.com.dashihui.web.dao.User;
import cn.com.dashihui.web.service.GoodsStoreService;
import cn.com.dashihui.web.service.StoreService;

/**
 * 分公司商品管理<br/>
 * 管理员可对分公司商品进行管理，以及审核
 */
public class GoodsStoreController extends BaseController{
	private GoodsStoreService service = Duang.duang(GoodsStoreService.class);
	private StoreService storeService =  Duang.duang(StoreService.class);
	/**
	 * 转到商品列表页面
	 */
	public void index(){
		Record record=service.countNumber();
		setAttr("tolnumber", record.get("tolnumber"));
		setAttr("sjshnumber", record.get("sjshnumber"));
		setAttr("sjnumber", record.get("sjnumber"));
		/*setAttr("xjshnumber", record.get("xjshnumber"));*/
		setAttr("xjnumber", record.get("xjnumber"));
		setAttr("bhnumber", record.get("bhnumber"));
		List<Record> listSeller=storeService.findAllSeller();
    	setAttr("listSeller", listSeller);
		render("index.jsp");
	}
	
	/**
	 * 列表页面异步请求数据
	 */
	public void page(){
		int pageNum = getParaToInt(0, 1);
		int pageSize = getParaToInt("pageSize", PropKit.getInt("constants.pageSize"));
		int goodId = getParaToInt("goodId",0);
		String index = getPara("index");//订单量、收藏量、浏览量从大到小排序条件
		String sellerId = getPara("sellerId");
		System.out.println(sellerId);
		String storeid = getPara("storeid");
		String sGoodName = getPara("sGoodName");
		System.out.println(storeid);
		String sBeginDate = getPara("sBeginDate");
		String sEndDate = getPara("sEndDate");
		String xBeginDate = getPara("xBeginDate");
		String xEndDate = getPara("xEndDate");
		int state = getParaToInt("pstate",0);	
		renderResult(0,service.findByPage(pageNum,pageSize,index,goodId,sGoodName,sellerId,storeid,sBeginDate,sEndDate,xBeginDate,xEndDate,state));
	}
	/**
	 * 拓客详情
	 */
	public void showToker(){
		int tokerid = getParaToInt("tokerid", 0);
		System.out.println(tokerid);
		GoodsTokerValue goodsToker = service.findToker(tokerid);
		setAttr("goodsToker", goodsToker);
		System.out.println(goodsToker);
		int oneUserid = goodsToker.get("oneUserid");
		User oneUser = service.findUser(oneUserid);
		
		String oneUserName = "--";
		if (oneUser!=null) {
			oneUserName = oneUser.get("name");
		} 
		setAttr("oneUserName", oneUserName);
		int twoUserid = goodsToker.get("twoUserid");
		
		User twoUser = service.findUser(twoUserid);
		
		String twoUserName = "--";
		if (twoUser!=null) {
			twoUserName = twoUser.get("name");
		} 
//		String twoUserName = twoUser.get("name");
		setAttr("twoUserName", twoUserName);
		int threeUserid = goodsToker.get("threeUserid");
		
		User threeUser = service.findUser(threeUserid);
		String threeUserName = "--";
		if (threeUser!=null) {
			 threeUserName = threeUser.get("name");
		} 
//		 threeUserName = threeUser.get("name");
		setAttr("threeUserName", threeUserName);
		int fourUserid = goodsToker.get("fourUserid");
		User fourUser = service.findUser(fourUserid);
		if (fourUser!=null) {
			String fourUserName = fourUser.get("name");
			setAttr("fourUserName", fourUserName);
		}
		int fiveUserid = goodsToker.get("fiveUserid");
		User fiveUser = service.findUser(fiveUserid);
		String fiveUserName = fiveUser.get("name");
		setAttr("fiveUserName", fiveUserName);
		render("showToker.jsp");
	}
	/**
	 * 转到团购商品列表页面
	 */
	public void groupbuying(){
		Record record=service.countNumbergb();
		setAttr("gbnumber", record.get("gbnumber"));
		setAttr("tolnumber", record.get("tolnumber"));
		setAttr("sjshnumber", record.get("sjshnumber"));
		setAttr("sjnumber", record.get("sjnumber"));
		/*setAttr("xjshnumber", record.get("xjshnumber"));*/
		setAttr("xjnumber", record.get("xjnumber"));
		setAttr("bhnumber", record.get("bhnumber"));
		List<Record> listSeller=storeService.findAllSeller();
    	setAttr("listSeller", listSeller);
    	System.out.println("页面跳转");
		render("groupbuying.jsp");
	}
	/**
	 * 列表页面异步请求数据
	 */
	public void pagegb(){
		System.out.println("查询团购商品");
		int pageNum = getParaToInt(0, 1);
		int pageSize = getParaToInt("pageSize", PropKit.getInt("constants.pageSize"));
		int goodId = getParaToInt("goodId",0);
		String sGoodName = getPara("sGoodName");
		String index = getPara("index");//订单量、收藏量、浏览量从大到小排序条件
		String sellerId = getPara("sellerId");
		String storeid = getPara("storeid");
		String sBeginDate = getPara("sBeginDate");
		String sEndDate = getPara("sEndDate");
		String xBeginDate = getPara("xBeginDate");
		String xEndDate = getPara("xEndDate");
		
		int state = getParaToInt("pstate",0);	

		renderResult(0,service.findByPagegb(pageNum,pageSize,index,goodId,sGoodName,sellerId,storeid,sBeginDate,sEndDate,xBeginDate,xEndDate,state));

	}
	/**
	 * 订单量、收藏量、浏览量从大到小排序条件
	 * 与列表页面异步  排序请求数据写到一起数据会重复
	 * 
	 */
	public void pageSort(){
		int pageNum = getParaToInt(0, 1);
		int pageSize = getParaToInt("pageSize", PropKit.getInt("constants.pageSize"));
		int goodId = getParaToInt("goodId",0);
		String sGoodName = getPara("sGoodName");
		String index = getPara("index");//订单量、收藏量、浏览量、历史销量从大到小排序条件
		String sellerId = getPara("sellerId");
		String storeid = getPara("storeid");
		String sBeginDate = getPara("sBeginDate");
		String sEndDate = getPara("sEndDate");
		String xBeginDate = getPara("xBeginDate");
		String xEndDate = getPara("xEndDate");
		int state = getParaToInt("pstate",0);		
		renderResult(0,service.findByPageSort(pageNum,pageSize,index,goodId,sGoodName,sellerId,storeid,sBeginDate,sEndDate,xBeginDate,xEndDate,state));
	}
	/**
	 * 订单量、收藏量、浏览量从大到小排序条件
	 * 与列表页面异步  排序请求数据写到一起数据会重复
	 * 
	 */
	public void pageSortgb(){
		int pageNum = getParaToInt(0, 1);
		int pageSize = getParaToInt("pageSize", PropKit.getInt("constants.pageSize"));
		int goodId = getParaToInt("goodId",0);
		String sGoodName = getPara("sGoodName");
		String index = getPara("index");//订单量、收藏量、浏览量、历史销量从大到小排序条件
		String sellerId = getPara("sellerId");
		String storeid = getPara("storeid");
		String sBeginDate = getPara("sBeginDate");
		String sEndDate = getPara("sEndDate");
		String xBeginDate = getPara("xBeginDate");
		String xEndDate = getPara("xEndDate");
		int state = getParaToInt("pstate",0);		
		renderResult(0,service.findByPageSortgb(pageNum,pageSize,index,goodId,sGoodName,sellerId,storeid,sBeginDate,sEndDate,xBeginDate,xEndDate,state));
	}

	/**
	 * 普通商品 日、周、月销售统计
	 */
	public void xspage(){
		int pageNum = getParaToInt(0, 1);
		int pageSize = getParaToInt("pageSize", PropKit.getInt("constants.pageSize"));
		int goodId = getParaToInt("goodId",0);
		String sellerId = getPara("sellerId");
		String sGoodName = getPara("sGoodName");
		String storeid = getPara("storeid");
		String sBeginDate = getPara("sBeginDate");
		String sEndDate = getPara("sEndDate");
		String xBeginDate = getPara("xBeginDate");
		String xEndDate = getPara("xEndDate");
		int state = getParaToInt("pstate",0);
		int date = getParaToInt("date",0);
		renderResult(0,service.findXSByPage(pageNum,pageSize,goodId,sGoodName,sellerId,storeid,sBeginDate,sEndDate,xBeginDate,xEndDate,state,date));
	}
	/**
	 * 团购商品 日、周、月销售统计
	 */
	public void xspagegb(){
		int pageNum = getParaToInt(0, 1);
		int pageSize = getParaToInt("pageSize", PropKit.getInt("constants.pageSize"));
		int goodId = getParaToInt("goodId",0);
		String sGoodName = getPara("sGoodName");
		String sellerId = getPara("sellerId");
		String storeid = getPara("storeid");
		String sBeginDate = getPara("sBeginDate");
		String sEndDate = getPara("sEndDate");
		String xBeginDate = getPara("xBeginDate");
		String xEndDate = getPara("xEndDate");
		int state = getParaToInt("pstate",0);
		int date = getParaToInt("date",0);
		renderResult(0,service.findXSByPagegb(pageNum,pageSize,goodId,sGoodName,sellerId,storeid,sBeginDate,sEndDate,xBeginDate,xEndDate,state,date));
	}
	/**
	 * 商品降权
	 */
	public void tooDown(){
		String id = getPara("id");
		if(StrKit.isBlank(id)){
			renderResult(1);
			return;
		}
		GoodsStore goods=service.findById(Integer.valueOf(id));
		goods.set("state", 5);
		goods.set("checktime",  DatetimeKit.getFormatDate("yyyy-MM-dd HH:mm:ss"));
		if(service.tooDown(goods)){
			renderSuccess();
			return;
		}
	}
	/**
	 * 商品信息页面
	 */
	public void goodDetail() {
		int id = getParaToInt("id", 0);
		int userid=getCurrentUser().getInt("id");
		if (id != 0) {
			Record goods = service.findGoodDetailById(id);
			String gooditem = goods.getStr("goodItem");
			String good_store = goods.getStr("good_store");
			// String LunBoNum=goods.getStr("LunBoNum");
			if (!StrKit.isBlank(gooditem)) {
				List<Record> goodItem = service.getGoodsItem(gooditem);
				if (goodItem.size() > 0) {
					setAttr("goodItem", goodItem);
				}
			}
			if (!StrKit.isBlank(good_store)) {
				List<Record> store = service.getStore(good_store);
				if (store.size() > 0) {
					setAttr("store", store);
				}
			}
				/*List<Record> goodSpecs = service.getGoodSpec(id);
				if (goodSpecs.size() > 0) {
					setAttr("goodSpec", goodSpecs);
				}*/
			
			setAttr("goods", goods);
		}
		List<GoodsSale> goodsSales = service.findAllSale(id);
		if (goodsSales.size() > 0) {
			setAttr("goodsSales", goodsSales);
		}
		setAttr("userid", userid);
		
		Record toker = service.findtoker(id);
		setAttr("toker", toker);
		List<Category> oneCategories = service.finOneCategory();
		setAttr("oneCategories", oneCategories);
		List<Category> twoCategories = service.findTwoCategory();
		setAttr("twoCategories", twoCategories);
		List<Category> threeCategories = service.findThreeCategory();
		setAttr("threeCategories", threeCategories);
		List<Category> fourCategories = service.findFourCategory();
		setAttr("fourCategories", fourCategories);
		List<GoodsSaleItem> saleItems = service.findSaleItem(id);
		setAttr("saleItems", saleItems);
		render("detail.jsp");
	} 
	/**
	 * 分公司产品修改商品信息页面
	 */
	public void toEdit(){
		int id = getParaToInt("id",0);
		if(id!=0){
			setAttr("object", service.findById(id));
		}
		render("edit.jsp");
	}
	public void edit(){
		int id=getParaToInt("id",0);
		int pstate=getParaToInt("pstate",0);
		if(id!=0&&pstate!=0){
			GoodsStore goods=service.findById(id);
			if(pstate==2){
				goods.set("pstate", pstate).set("stock", 0);
			}else{
				goods.set("pstate", pstate);
			}
			goods.set("checktime",  DatetimeKit.getFormatDate("yyyy-MM-dd HH:mm:ss"));
			if(service.edit(goods)){
				renderSuccess(service.findPageById(Integer.valueOf(id)));
				return;
			}else{
				renderResult(1);
				return;
			}
		}else{
			renderResult(1);
			return;
		}
	}
	/**
	 * 商品订单
	 */
	public void goodsOrderindex(){
		int id = getParaToInt("id",0);
		String sellerId = getPara("sellerId");
		String name = getPara("name");
		if(id!=0&&!StrKit.isBlank(sellerId)&&!StrKit.isBlank(name)){
			setAttr("sellerId", sellerId);
			setAttr("name", name);
			setAttr("object", service.findById(id));
		}
		render("goodsOrder.jsp");
	}
	/**
	 * 团购订单
	 */
	public void gbgoodsOrderindex(){
		int id = getParaToInt("id",0);
		String sellerId = getPara("sellerId");
		String name = getPara("name");
		if(id!=0&&!StrKit.isBlank(sellerId)&&!StrKit.isBlank(name)){
			setAttr("sellerId", sellerId);
			setAttr("name", name);
			setAttr("object", service.findById(id));
		}
		render("gbgoodsOrder.jsp");
	}
	/**
	 * 获得订单列表数据
	 */
	public void goodsOrder(){
		int pageNum = getParaToInt(0, 1);
		int pageSize = getParaToInt("pageSize", PropKit.getInt("constants.pageSize"));
		//订单编号
		String orderNum = getPara("orderNum");
		//下单时间范围
		String beginDate = getPara("beginDate");
		String endDate = getPara("endDate");
		//订单状态
		int state = getParaToInt("state",0);
		//买家电话
		String tel = getPara("tel");
		int seid = 0;
		int stid = 0;
		//公司ID
		String sellerId=getPara("sellerId");
		if (StrKit.notBlank(sellerId)) {
			Seller seller = storeService.findSeller(sellerId);
			seid = seller.getInt("id");
		}
		//分公司ID
		String storeId=getPara("storeId");
		if (StrKit.notBlank(storeId)) {
			Store store = storeService.findByStoreid(storeId);
	 		stid = store.getInt("id");
		}
		//商品Id
		int id=getParaToInt("id",0);
		System.out.println("商品id"+id);
		renderResult(0,service.goodsOrder(pageNum,pageSize,orderNum,beginDate,endDate,state,seid,tel,stid,id));
	}
	/**
	 * 获得团购订单列表数据
	 */
	public void goodsOrdergb(){
		int pageNum = getParaToInt(0, 1);
		int pageSize = getParaToInt("pageSize", PropKit.getInt("constants.pageSize"));
		//订单编号
		String orderNum = getPara("orderNum");
		//下单时间范围
		String beginDate = getPara("beginDate");
		String endDate = getPara("endDate");
		//订单状态
		int state = getParaToInt("state",0);
		//买家电话
		String tel = getPara("tel");
		int seid = 0;
		int stid = 0;
		//公司ID
		String sellerId=getPara("sellerId");
		if (StrKit.notBlank(sellerId)) {
			Seller seller = storeService.findSeller(sellerId);
			seid = seller.getInt("id");
		}
		//分公司ID
		String storeId=getPara("storeId");
		if (StrKit.notBlank(storeId)) {
			Store store = storeService.findByStoreid(storeId);
	 		stid = store.getInt("id");
		}
		//商品Id
		int id=getParaToInt("id",0);
		System.out.println("商品id"+id);
		renderResult(0,service.goodsOrdergb(pageNum,pageSize,orderNum,beginDate,endDate,state,seid,tel,stid,id));
	}
	/**
	 * 图片列表
	 */
	public void imageIndex(){
    	setAttr("LunBoNum", getPara(0));
        render("imageList.jsp");
    }
	/**
	 * 图片分页
	 */
    public void imagePage(){
    	renderSuccess(service.findAllImages(getPara(0)));
    }
    /**
 	 * 添加详情图片列表
 	 */
 	public void imageDetailIndex(){
     	setAttr("LunBoNum", getPara(0));
         render("detailImgList.jsp");
     }
 	/**
 	 * 详情图片分页
 	 */
     public void imageDetailPage(){
     	renderSuccess(service.findDetailAllImages(getPara(0)));
     }
	/**
	 * excel导出普通商品
	 */
	public void doExcel(){
		List<Pair> titles = new ArrayList<Pair>();
	    titles.add(new Pair("id", "商品ID"));
	    titles.add(new Pair("name", "商品名称"));
	    titles.add(new Pair("ftype", "适用阶段"));
	    titles.add(new Pair("sellerName", "所属公司"));
	    titles.add(new Pair("countStore", "上架分公司数量"));
	   /* titles.add(new Pair("stock", "库存数量"));
	    titles.add(new Pair("paytype", "积分类型"));
	    titles.add(new Pair("sellpoint", "所需积分"));
	    titles.add(new Pair("sellPrice", "现金价格"));*/
	    titles.add(new Pair("countSell", "订单量"));
	    titles.add(new Pair("countCon", "收藏量"));
	    titles.add(new Pair("conNum", "浏览量"));
	    titles.add(new Pair("checktime", "改动时间"));
	    titles.add(new Pair("pstate", "当前状态"));
	    titles.add(new Pair("tState", "拓客状态"));
	    
	    int goodId = getParaToInt("goodId",0);
		String sellerId = getPara("sellerId");
		String storeid = getPara("storeid");
		String sGoodName = getPara("sGoodName");
		String sBeginDate = getPara("sBeginDate");
		String sEndDate = getPara("sEndDate");
		String xBeginDate = getPara("xBeginDate");
		String xEndDate = getPara("xEndDate");
		int state = getParaToInt("pstate",0);
		int date = getParaToInt("date",0);
		List<Record> list=service.findExcelByPage(goodId,sGoodName,sellerId,storeid,sBeginDate,sEndDate,xBeginDate,xEndDate,state,date);
		List<Record> listz=new ArrayList<Record>();
		for (int i = 0; i < list.size(); i++) {
			Record record=new Record();
				record.set("id",list.get(i).get("id"));
				record.set("name", list.get(i).get("name"));
				if(list.get(i).get("ftype").equals(713)){
					record.set("ftype", "常规");
				}else if(list.get(i).get("ftype").equals(714)){
					record.set("ftype", "团购");
				}
				if(list.get(i).get("tState")!=null&&list.get(i).get("tState").equals(1)){
					record.set("tState", "打开");
				}else if(list.get(i).get("tState")==null||list.get(i).get("tState").equals(0)){
					record.set("tState", "关闭");
				}
				record.set("sellerName", list.get(i).get("sellerName"));
				/*record.set("stock", list.get(i).get("stock"));
				if(list.get(i).get("paytype").equals(1)){
					record.set("paytype", "积分");
				}else if(list.get(i).get("paytype").equals(2)){
					record.set("paytype", "抵扣券");
				}else if(list.get(i).get("paytype").equals(3)){
					record.set("paytype", "惠券");
				}
				record.set("sellpoint", list.get(i).get("sellpoint"));
				record.set("sellPrice", list.get(i).get("sellPrice"));*/
				record.set("countStore", list.get(i).get("countStore"));
				record.set("countSell", list.get(i).get("countSell"));
				record.set("countCon", list.get(i).get("countCon"));
				record.set("conNum", list.get(i).get("conNum"));
				record.set("checktime", list.get(i).get("checktime"));
				if(list.get(i).get("pstate").equals(1)){
					if(list.get(i).get("state").equals(1)){
						record.set("pstate", "上架审核中");
					}else if(list.get(i).get("state").equals(2)){
						record.set("pstate", "上架");
					}else if(list.get(i).get("state").equals(3)){
						record.set("pstate", "下架");
					}
				}else if(list.get(i).get("pstate").equals(2)){
					record.set("pstate", "售罄");
				}else if (list.get(i).get("pstate").equals(3)){
					record.set("pstate", "降权");
				}
			listz.add(record);
 		}
		// 导出
		service.export(getResponse(), getRequest(),titles, listz);		
		renderNull();
	}
	/**
	 * excel导出团购商品
	 */
	public void doExcelgb(){
		List<Pair> titles = new ArrayList<Pair>();
	    titles.add(new Pair("id", "商品ID"));
	    titles.add(new Pair("name", "商品名称"));
	    titles.add(new Pair("ftype", "适用阶段"));
	    titles.add(new Pair("sellerName", "所属公司"));
	    titles.add(new Pair("countStore", "上架分公司数量"));
	   /* titles.add(new Pair("stock", "库存数量"));
	    titles.add(new Pair("paytype", "积分类型"));
	    titles.add(new Pair("sellpoint", "所需积分"));
	    titles.add(new Pair("sellPrice", "现金价格"));*/
	    titles.add(new Pair("countSell", "订单量"));
	    titles.add(new Pair("countCon", "收藏量"));
	    titles.add(new Pair("conNum", "浏览量"));
	    titles.add(new Pair("checktime", "改动时间"));
	    titles.add(new Pair("pstate", "当前状态"));
	    titles.add(new Pair("tState", "拓客状态"));
	    
	    int goodId = getParaToInt("goodId",0);
		String sellerId = getPara("sellerId");
		String storeid = getPara("storeid");
		String sGoodName = getPara("sGoodName");
		String sBeginDate = getPara("sBeginDate");
		String sEndDate = getPara("sEndDate");
		String xBeginDate = getPara("xBeginDate");
		String xEndDate = getPara("xEndDate");
		int state = getParaToInt("pstate",0);
		int date = getParaToInt("date",0);
		List<Record> list=service.findExcelByPagegb(goodId,sGoodName,sellerId,storeid,sBeginDate,sEndDate,xBeginDate,xEndDate,state,date);
		List<Record> listz=new ArrayList<Record>();
		for (int i = 0; i < list.size(); i++) {
			Record record=new Record();
				record.set("id",list.get(i).get("id"));
				record.set("name", list.get(i).get("name"));
				if(list.get(i).get("ftype").equals(713)){
					record.set("ftype", "常规");
				}else if(list.get(i).get("ftype").equals(714)){
					record.set("ftype", "团购");
				}
				if(list.get(i).get("tState")!=null&&list.get(i).get("tState").equals(1)){
					record.set("tState", "打开");
				}else if(list.get(i).get("tState")==null||list.get(i).get("tState").equals(0)){
					record.set("tState", "关闭");
				}
				record.set("sellerName", list.get(i).get("sellerName"));
				/*record.set("stock", list.get(i).get("stock"));
				if(list.get(i).get("paytype").equals(1)){
					record.set("paytype", "积分");
				}else if(list.get(i).get("paytype").equals(2)){
					record.set("paytype", "抵扣券");
				}else if(list.get(i).get("paytype").equals(3)){
					record.set("paytype", "惠券");
				}
				record.set("sellpoint", list.get(i).get("sellpoint"));
				record.set("sellPrice", list.get(i).get("sellPrice"));*/
				record.set("countStore", list.get(i).get("countStore"));
				record.set("countSell", list.get(i).get("countSell"));
				record.set("countCon", list.get(i).get("countCon"));
				record.set("conNum", list.get(i).get("conNum"));
				record.set("checktime", list.get(i).get("checktime"));
				if(list.get(i).get("pstate").equals(1)){
					if(list.get(i).get("state").equals(1)){
						record.set("pstate", "上架审核中");
					}else if(list.get(i).get("state").equals(2)){
						record.set("pstate", "上架");
					}else if(list.get(i).get("state").equals(3)){
						record.set("pstate", "下架");
					}
				}else if(list.get(i).get("pstate").equals(2)){
					record.set("pstate", "售罄");
				}else if (list.get(i).get("pstate").equals(3)){
					record.set("pstate", "降权");
				}
			listz.add(record);
 		}
		// 导出
		service.export(getResponse(), getRequest(),titles, listz);		
		renderNull();
	}
	/**
	 * 跳转收藏此商品的用户信息页面
	 */
	public void countCon(){
		int goodsId=getParaToInt("goodsId", 0);		
		setAttr("goodsId",goodsId);
		setAttr("goods",service.findGoodsById(goodsId));
		render("collect.jsp");
	}
	/**
	 * 收藏此商品的用户信息列表
	 */
	public void doCountCon(){
		int goodsId=getParaToInt("goodsId", 0);	
		int pageNum = getParaToInt(0, 1);
		int pageSize = getParaToInt("pageSize", PropKit.getInt("constants.pageSize"));
		renderResult(0,service.findGoodsByCountCon(pageNum,pageSize,goodsId));	
	}
	/**
	 * excel导出 收藏此商品的用户信息列表
	 */
	public void doCollectExcel() {
		/*String operationMsg = "excel导出";*/
		List<Pair> titles = new ArrayList<Pair>();
		titles.add(new Pair("id", "商品ID"));
		titles.add(new Pair("name", "会员名称"));
		titles.add(new Pair("phone", "会员手机号"));
		titles.add(new Pair("store", "所属分公司"));
		titles.add(new Pair("toBossOneId", "办卡销售"));
		titles.add(new Pair("createDate", "办卡日期"));
		titles.add(new Pair("state", "会员状态"));
		titles.add(new Pair("amount", "消费总金额"));
		titles.add(new Pair("sppoint", "积分"));
		titles.add(new Pair("jkpoint", "抵扣券"));
		titles.add(new Pair("jypoint", "惠券"));
		titles.add(new Pair("ordernum", "兑换次数"));
		int goodsId = getParaToInt("goodsId",0);
		List<Record> list = service.findGoodsByCountConExcel(goodsId);
		List<Record> listz = new ArrayList<Record>();
		for (int i = 0; i < list.size(); i++) {
			Record record = new Record();
			record.set("id", list.get(i).get("id"));
			record.set("name", list.get(i).get("name"));
			record.set("phone", list.get(i).get("phone"));
			record.set("store", list.get(i).get("store"));
			record.set("toBossOneId", list.get(i).get("toBossOneId"));
			record.set("createDate", list.get(i).get("createDate"));
			if(list.get(i).get("state").equals(1)){
				record.set("state","未登录");
			}else if(list.get(i).get("store").equals(2)){
				record.set("state","未注册");
			}else{
				record.set("state", "会员");
			}
			if(list.get(i).get("amount")==null){
				record.set("amount",0);
			}else{
				record.set("amount", list.get(i).get("amount"));
			}
			record.set("sppoint", list.get(i).get("sppoint"));
			record.set("jkpoint", list.get(i).get("jkpoint"));
			record.set("jypoint", list.get(i).get("jypoint"));			
			record.set("ordernum", list.get(i).get("ordernum"));
			listz.add(record);
		}
		// 导出
		service.export(getResponse(), getRequest(), titles, listz);
		renderNull();
	}
	//根据公司查询分公司
		public void chooseStore(){
			String[] sSellerId = getParaValues("sSellerId");
			String str = java.lang.String.join("','", sSellerId);
			renderSuccess(storeService.chooseStore(str));
		}
}
